home *** CD-ROM | disk | FTP | other *** search
- class FPUI.NButton extends FPUI.Component
- {
- var m_iconMC;
- var m_active = false;
- var m_keyHandler = null;
- var m_state = "up";
- var m_iconName = "";
- var m_clickHandler = "";
- var m_localName = "";
- function NButton()
- {
- var _loc1_ = this;
- super();
- _loc1_.stop();
- _loc1_.useHandCursor = false;
- if(_loc1_.m_iconName != "")
- {
- var _loc2_ = _loc1_.attachMovie(_loc1_.m_iconName,"m_iconMC",99);
- _loc2_._x = Math.round((_loc1_._width - _loc2_._width) / 2);
- _loc2_._y = Math.round((_loc1_._height - _loc2_._height) / 2);
- _loc2_.tabEnabled = false;
- }
- if(_loc1_._accImpl != null)
- {
- delete _loc1_._accImpl;
- _loc1_._accImpl = null;
- }
- }
- function onComponentSetFocus()
- {
- super.onComponentSetFocus();
- this.go("focus");
- }
- function onComponentKillFocus()
- {
- super.onComponentKillFocus();
- this.go("up");
- }
- function go(s)
- {
- var _loc1_ = s;
- var _loc2_ = this;
- _loc2_.m_state = _loc1_;
- if(!_loc2_.m_enable)
- {
- _loc1_ = "up";
- }
- else if(_loc1_ == "up")
- {
- if(_loc2_.m_active)
- {
- _loc1_ = "over";
- }
- else if(_loc2_.getFocused())
- {
- _loc1_ = "focus";
- }
- }
- else if(_loc1_ == "focus" && _loc2_.m_active)
- {
- _loc1_ = "over";
- }
- _loc2_.gotoAndStop(_loc1_);
- }
- function setEnabled(enabledFlag)
- {
- super.setEnabled(enabledFlag);
- this.m_iconMC._alpha = !this.m_enable ? 50 : 100;
- }
- function setActive(a)
- {
- var _loc1_ = this;
- _loc1_.m_active = a;
- _loc1_.go(_loc1_.m_state);
- }
- function isActive()
- {
- return this.m_active;
- }
- function findListener(method)
- {
- var _loc2_ = method;
- var _loc1_ = this._parent;
- while(_loc1_ != null)
- {
- if(_loc1_.controller != undefined && _loc1_.controller[_loc2_] != undefined)
- {
- return _loc1_.controller;
- }
- _loc1_ = _loc1_._parent;
- }
- return null;
- }
- function sendListener(method)
- {
- var _loc1_ = this.findListener(method);
- if(_loc1_ != null)
- {
- _loc1_[method]();
- }
- }
- function setKeyHandler(h)
- {
- this.m_keyHandler = h;
- }
- function onComponentKeyDown()
- {
- var _loc1_ = this;
- if(_loc1_.m_keyHandler)
- {
- _loc1_.m_keyHandler.onKeyDown();
- }
- else if(Key.getCode() == 13)
- {
- _loc1_.sendListener(_loc1_.m_clickHandler);
- }
- }
- function onDragOver()
- {
- this.go("down");
- }
- function onDragOut()
- {
- this.go("up");
- }
- function onRollOver()
- {
- this.go("over");
- }
- function onRollOut()
- {
- this.go("up");
- }
- function onPress()
- {
- this.go("down");
- }
- function onRelease()
- {
- var _loc1_ = this;
- if(_loc1_.m_enable)
- {
- _loc1_.sendListener(_loc1_.m_clickHandler);
- }
- _loc1_.go("over");
- }
- function onReleaseOutside()
- {
- this.go("up");
- }
- }
-